<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include/head::commonHeaderCustom('baseSalaryConfigure',~{::style})">
    <!--<body oncontextmenu="self.event.returnValue=false" onselectstart="return false">-->
<!--<link rel="stylesheet"  th:href="@{/static/css/}" />-->
    <style>
        @media screen and (max-width: 1100px){
            .layui-layer-iframe {
                overflow-y: visible !important;
            }
        }
    </style>


<body>
<div id="content" class="col-lg-12 col-sm-12">
    <div class="row">
        <div class="box col-md-12">
            <div class="box-inner">
                <div class="box-header well" data-original-title="">
                    <h2>
                        <i class="glyphicon glyphicon-user"></i> 学员成绩收集消息列表
                    </h2>
                    <div class="box-icon">
                        <!-- <a href="#" class="btn btn-setting btn-round btn-default"><i class="glyphicon glyphicon-cog"></i></a> -->
                        <a href="javascript:void(0);" id="smaller" class="btn btn-minimize btn-round btn-default"><i class="glyphicon glyphicon-chevron-up"></i></a>
                        <!-- <a href="#"	class="btn btn-close btn-round btn-default"><i class="glyphicon glyphicon-remove"></i></a> -->
                    </div>
                </div>
                <div class="box-content">
                    <form class="form-inline" style="margin-bottom:0.5%" id="searchForm" role="form" method="post"
                          th:action="${#request.getRequestURI()}">
                            <div class="form-group ">
                                <select name="pageSize"  class="form-control input-sm" >
                                    <option value="10" th:selected="${pageSize==10}">10条/页</option>
                                    <option value="25" th:selected="${pageSize==25}">25条/页</option>
                                    <option value="50" th:selected="${pageSize==50}">50条/页</option>
                                </select>
                            </div>

                        <div class="form-group">
                            <input id="year" name="time" th:value="${time}"  class="form-control input-sm" maxlength="10" style="width:100px;" placeholder="请选择年度" title="年份" onfocus="WdatePicker({dateFmt: 'yyyy', isShowToday: false, isShowClear: false })" autocomplete="off"/>
							<button class="btn btn-info btn-sm" type="submit"> 查 询 </button>
							<a href="javascript:void(0)" class="btn btn-primary btn-sm " onclick="wechatTemplate();">
							<span class="glyphicon glyphicon-check"></span> 添加推送 </a>
                        </div>
                        <div class="form-group" style="display: none">
                                <div class="input-group input-group-sm">
                                    <input type="hidden" th:value="${pageInfo.pageNum}" name="pageNum" id="pageNum">
                                </div>
						</div>

                    </form>
                    <table class="table table-striped table-bordered table-hover footable" data-show-toggle="false">
                        <thead>
							<tr>
								<th style="text-align: center;" data-breakpoints="xs">序号</th>
								<th style="text-align: center;white-space:nowrap;">添加人</th>
								<th style="text-align: center;white-space:nowrap;">年度</th>
								<th style="text-align: center;white-space:nowrap;">学期</th>
								<th style="text-align: center;white-space:nowrap;">考试</th>
                                <th style="text-align: center;white-space:nowrap;">推送次数</th>
                                <th style="text-align: center;white-space:nowrap;">已推送次数</th>
                                <th style="text-align: center;white-space:nowrap;">录入时间</th>
								<th style="text-align: center;white-space:nowrap;" data-breakpoints="xs">操作</th>
							</tr>
                        </thead>
                        <tbody>
							 <tr th:each="list,listStat: ${pageInfo.list}">
                                 <td style="text-align: center;" th:text="${listStat.index+1}"></td>
							    <td style="text-align: center;" th:text="${list.studentLogin}"></td>
								<td style="text-align: center;" th:text="${#dates.format(list.year, 'yyyy')}"></td>
								<td style="text-align: center;" th:if="${list.term == 1}"> 上学期</td>
								<td style="text-align: center;" th:if="${list.term == 2}"> 下学期</td>
								<td style="text-align: center;" th:if="${list.testTime == 1}"> 期中</td>
								<td style="text-align: center;" th:if="${list.testTime == 2}"> 期末</td>
                                 <td style="text-align: center;" th:text="${list.pushTimes}"> 推送次数</td>
                                 <td style="text-align: center;" th:text="${list.alreadyPushTimes}"> 已推送次数</td>
								<td style="text-align: center;" th:text="${#dates.format(list.addTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
								<td style="text-align: left;">
									 <a th:if="${session.menuMap[244] != null and session.menuMap['244'] !=''}"  th:attr="data-id=${list.id}"  onclick="pushMsg(this)"  class="btn btn-primary eidt"><span class="glyphicon glyphicon-edit"></span> 推 送 </a>
									 <!--<a  th:attr="data-id=${list.id}"  onclick="delAchievement(this)"  class="btn btn-danger opblock-delete"><span class="glyphicon glyphicon-remove"></span> 删 除 </a>-->
								</td>
							 </tr>
                        </tbody>
                    </table>
                    <div th:include="include/pageinfo::pager"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include/onload_js::onloadJSCustomList(~{::script})">
    <script>
		$(function(){
		     //自适应表格
            $('.footable').footable();
		});

	//成绩收集 微信 消息推送模板
	function wechatTemplate(){
		var url = "/achievementCollectionManager/wechatTemplate";
		layer.open({
			type: 2,
			title: false,
			closeBtn: 2, //显示关闭按钮
			shade: [0],
			area: ['500px', '400px'], //宽高
			//offset: 'rb', //右下角弹出
			// time: 2000, //2秒后自动关闭
			anim: 2,
			content: [url, 'no'], //iframe的url，no代表不显示滚动条
			end: function () { //此处用于演示
			}
		});
	}

	function pushMsg(obj){
	    var id = $(obj).attr("data-id")
        var content = "您确认发送成绩收集通知吗？系统会将推送通知到微信消息";
        layer.confirm(content, {
          btn: ['是','否'] //按钮
          ,cancel: function(index, layero){
            //取消操作，点击右上角的X
          }
        }, function(){
            $.ajax({
                type:'post',
                url:'/achievementCollectionManager/pushWechatMsg',
                data:{'wechatAchievementMsgId' : id},
                cache:false,
                async: false,
                dataType:'json',
                success:function(data){
                    if(data.code>0){
                        layer.msg(data.msg,{
                          offset:['50%'],
                          time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    },function(){
                      window.location.reload();
                    });
                    }else{
                        layer.msg(data.msg);
                    }
                }
            });
        }, function(){
        //否
        });
    }


	function delAchievement (obj){
	    var id = $(obj).attr("data-id")
	    layer.confirm('是否确认删除？删除后数据不可恢复', {
          btn: ['是','否'] //按钮
          ,cancel: function(index, layero){
            //取消操作，点击右上角的X
          }
        }, function(){
            $.ajax({
                type:'post',
                url:'/achievementCollectionManager/delAchievement',
                data:{'id' : id},
                cache:false,
                async: false,
                dataType:'json',
                success:function(data){
                    if(data.code>0){
                        layer.msg('删除成功',{
                          offset:['50%'],
                          time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    },function(){
                      window.location.reload();
                    });
                    }else{
                        layer.msg("删除失败");
                    }
                }
            });
        }, function(){
        //否
        });
	}
    </script>
</div>
</body>
</html>
